package com.example.shiyansan.mapper;


import com.example.shiyansan.entity.Book;
import com.example.shiyansan.result.Result;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Controller;

import java.util.List;

@Mapper
public interface BookMapper {

    @Select("select * from book")
    List<Book> findBookList();

    /**
     * .通过图书id来查看图书的数量
     * @param bookId
     */
    @Select("select stock from book where book_id = #{bookId}")
    int findBookStock(int bookId);

    /**
     * 通过id来查询图书的详细信息
     * @param id
     * @return
     */
    @Select("select * from book where book_id = #{bookId}")
    Book findBookById(int id);

    /**
     * 更新图书
     * @param book
     */
    void updateBook(Book book);

    /**
     * 更新库存
     * @param book
     */
    void updateStock(Book book);
}
